package com.yanqu.road.server.cmd.activity.soulbone;

import com.yanqu.road.entity.activity.soulbone.SoulBoneUserData;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.SoulBoneProto;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.command.Command;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.activity.soulbone.SoulBoneModule;
import com.yanqu.road.server.manger.player.GamePlayerMgr;
import com.yanqu.road.server.protocol.Protocol;
import io.netty.channel.ChannelHandlerContext;

@Cmd(code = Protocol.S_SOUL_BONE_NOTICE_SYNC, desc = "跑马灯同步")
public class SoulBoneNoticeSyncCmd implements Command {

    @Override
    public void execute(ChannelHandlerContext ctx, YanQuMessage yanQuMessage) throws Exception {

        for (GamePlayer gamePlayer : GamePlayerMgr.getAllOnlinePlayer()) {
            SoulBoneUserData userData = gamePlayer.getModule(SoulBoneModule.class).getUserData();
            if(userData != null){
                gamePlayer.sendPacket(Protocol.U_SOUL_BONE_NOTICE_SYNC, SoulBoneProto.SoulBoneConfigDataSyncMsg.parseFrom(yanQuMessage.getBytes()).toBuilder());
            }
        }
    }
}
